package com.wsk.controller;

import com.wsk.pojo.UserInformation;
import com.wsk.pojo.UserPassword;
import com.wsk.service.ZhuCeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
public class ZhuCeController {
    @Resource
    ZhuCeService zhuCeService;

    @RequestMapping("/zhuce/toadd")
    public String toadd(){
        return "/page/zhuce";
    }
    @RequestMapping("/zhuce/add")
    public String add(UserInformation userInformation, UserPassword userPassword){
        zhuCeService.insert(userInformation);
        System.out.println("到这第一个添加成功了");
        System.out.println(userInformation.getUsername());
        UserInformation user = zhuCeService.getUserByUserName(userInformation.getUsername());
        System.out.println("进行了查询");
        userPassword.setUid(user.getId());
        System.out.println("数据校验 uid"+userPassword.getUid()+"|password"+userPassword.getPassword());
        zhuCeService.insert1(userPassword);
        return "redirect:/login.do";
    }
}
